<?php

namespace common\models\projectpaid;

use Yii;
use common\models\projectaccounttype\ProjectAccounttype;

/**
 * This is the model class for table "project_paid".
 *
 * @property integer $id
 * @property string $time
 * @property string $description
 * @property string $money
 * @property string $content
 * @property integer $category
 */
class ProjectPaid extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'project_paid';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['time', 'description', 'money', 'content', 'category', 'account_type'], 'required'],
            [['money'], 'number'],
            [['category', 'time', 'account_type'], 'integer'],
            [['description', 'content', 'attachment'], 'string', 'max' => 255],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => Yii::t('app', 'ID'),
            'time' => Yii::t('app', '日期'),
            'description' => Yii::t('app', '说明'),
            'money' => Yii::t('app', '金额（元）'),
            'content' => Yii::t('app', '内容'),
            'category' => Yii::t('app', '项目名称'),
            'account_type' => Yii::t('app', '账户类型'),
            'attachment' => Yii::t('app', '附件'),
        ];
    }
    // 获取账户类型
    public static function getAccount($id){
         if(ProjectAccounttype::findOne($id)){
            return ProjectAccounttype::findOne($id)->name;
        }else{
            return '';
        }
    }
}
